version: '3.8'

services:

  javacode:
    image: javacode:latest
    container_name: javacode
    ports:
      - "8080:8080"
    build:
      context: .
      dockerfile: Dockerfile
    depends_on:
      - database
      - redis
    networks:
      - shared_network

  database:
    image: postgres:latest
    container_name: database
    environment:
      POSTGRES_USER: gleb
      POSTGRES_PASSWORD: stringst
      POSTGRES_DB: database
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    networks:
      - shared_network

  redis:
    image: redis:latest
    container_name: redis
    environment:
      - REDIS_PASSWORD=mysecretpassword
      - REDIS_REPLICATION_MODE=master
      - REDIS_LOGLEVEL=notice
      - REDIS_MAXMEMORY 128mb
      - REDIS_MAXMEMORYPOLICY allkeys-lru
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/var/lib/redis/data/
    networks:
      - shared_network

volumes:
  postgres_data:
  redis_data:

networks:
  shared_network:
    external: true
